<template>
	<view>
		<video-player v-if="playletshow" album-Id="albumId" episode-Id="episodeId"  bindplay="playhandler" :autoplay="true" 
		id="myVideo" data-city="beijing" cloud-type="cloudType"
		version="version" :error="cptEventAssert" :play="cptEventAssert" >	
		</video-player>
	</view>
</template>

<script>
	export default {
		data() {
			return {
			   playletshow: false,
			    albumId: '7293352275597558282d',
			    episodeId: '7293352552546959907',
			    cloudType: 1,
			    version: 1	
			}
		},
		onLoad(){
			tt.canIUse('video-player')
				this.preloadplaylet()
		},
		methods: {
			cptEventAssert (event) {
			  console.log("event", event)
			},
			preloadplaylet() {
			  tt.preloadResourceVideo({
			    albumId: this.albumId,
			    episodeId: this.episodeId,
			    cloudType: this.cloudType,
			    version: this.version,
			    success: () => {
								   console.log('短剧预加载成功')
			      tt.showToast({
			        title: '短剧预加载成功', // 内容
			      });
			      this.playletshow = true
			      
			    },
			    fail: (error) => {
			      console.log("短剧预加载失败", error);
			      tt.showToast({
			        icon: 'fail',
			        title: '短剧预加载失败'
			      })
			      this.playletshow = true
			    },
			  });
			},
		}
	}
</script>

<style>

</style>
